import { request } from '@/utils/request'
import { findByStorageKey } from '@/utils/localStorageUtil'

// 分页查询
export const getBrandByPage = (currentPage: number) => {
  const accessToken = findByStorageKey('accessToken')
  return request.get('/brand/page', {
    headers: {
      accessToken
    },
    params: {
      pageNum: currentPage,
      pageSize: 10
    }
  })
}

//删除
export const deleteBatch = (idList: any) => {
  const accessToken = findByStorageKey('accessToken')
  const customHeaders = {
    // 设置正确的请求头格式
    Authorization: `Bearer ${accessToken}`,
    accessToken: accessToken
  }
  return request.delete('/brand/deleteBatch', {
    data: {
      idList
    },
    headers: customHeaders
  })
}

//添加品牌
export const saveBrand = (data: any) => {
  const accessToken = findByStorageKey('accessToken')
  return request.post('/brand/save', data, {
    headers: {
      // 设置正确的请求头格式
      Authorization: `Bearer ${accessToken}`,
      accessToken: accessToken
    }
  })
}

//修改品牌
export const updateBrand = (data: any) => {
  const accessToken = findByStorageKey('accessToken')
  return request.put('/brand/update', data, {
    headers: {
      // 设置正确的请求头格式
      Authorization: `Bearer ${accessToken}`,
      accessToken: accessToken
    }
  })
}
